package com.hnichr.ump.api.controller;

import com.hnichr.ump.common.salon.entity.Applicants;
import com.hnichr.ump.common.salon.service.ApplicantsService;
import com.mxpioframework.common.vo.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "ApplicantsApiController", description = "沙龙报名接口")
@RestController
@RequestMapping("/api/applicant/")
public class ApplicantsApiController {

    @Autowired
    private ApplicantsService applicantsService;

    @GetMapping("get/{mobile}/{salonId}")
    @Operation(summary = "根据手机号和沙龙id获取报名者信息", description = "根据手机号和沙龙id获取报名者信息", method = "GET")
    public Result<Applicants> getApplicant(@Parameter(description="mobile") @PathVariable(name = "mobile", required = true) String mobile,
                                           @Parameter(description="salonId") @PathVariable(name = "salonId", required = true) String salonId) {
        Applicants applicants = applicantsService.getApplicantInfo(salonId,mobile);
        return Result.OK(applicants);
    }

    @GetMapping("signin/{mobile}/{salonId}")
    @Operation(summary = "根据手机号和沙龙id签到", description = "根据手机号和沙龙id签到", method = "GET")
    public Result<Applicants> signIn(@Parameter(description="mobile") @PathVariable(name = "mobile", required = true) String mobile,
                                           @Parameter(description="salonId") @PathVariable(name = "salonId", required = true) String salonId) {
        Applicants applicants =  applicantsService.signIn(salonId,mobile);
        return Result.OK(applicants);
    }
}
